/**
 * @project_name staff_vehicle
 * @package_name com.ssh.web.admin
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-4-28
 * @time 上午9:57:25
 */
package com.ssh.web.admin;

import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.entity.VisitorTable;
import com.ssh.model.pdata.VVisitInfoPData;
import com.ssh.ser.admin.VisitorManageSerI;

/**
 * @author jack
 *
 */
public class QueryVisitorAction extends ActionSupport {

	/**
	 * TODO
	 */
	private static final long serialVersionUID = 1L;
	private String respondentId;
	private Timestamp VInTime;
	private String visitorId;
	private List<VVisitInfoPData> visitorInfoList;
	private List<VisitorTable> visitorList;
	private VisitorManageSerI visitorManageSerI;
	private String VOffPicture;
	private Timestamp VOffTime;

	/*
	 * (non-Javadoc)
	 *
	 * @see com.opensymphony.xwork2.ActionSupport#execute()
	 */

	public String viewAllVVisit() {
		try {
			DateFormat format1 = new SimpleDateFormat("yyyy-MM-dd");
			DateFormat format2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			// format2.format(format1.parse(VInTime));
			// format2.format(format1.parse(VOffTime));
			VisitorTable visitor = new VisitorTable();
			if (!visitorId.equals(""))
				visitor.setVisitorId(visitorId);
			if (!respondentId.equals(""))
				visitor.setRespondentId(respondentId);
			/*
			 * if (!VInTime.equals("")){
			 * visitor.setVInTime(Timestamp.valueOf(format2
			 * .format(format1.parse(VInTime)))); }
			 *
			 * if (!VOffTime.equals("")){
			 * visitor.setVOffTime(Timestamp.valueOf(format2
			 * .format(format1.parse(VOffTime)))); }
			 */
			if (!VOffPicture.equals(""))
				visitor.setVOffPicture(VOffPicture);
			visitorInfoList = visitorManageSerI.viewAllVVisitInfo();
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "ok";
	}

	public String viewByInTime() {
		try {
			visitorInfoList = visitorManageSerI.viewVVisitByInTime(VInTime);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "ok";
	}

	public String viewByOffTime() {
		try {
			visitorInfoList = visitorManageSerI.viewVVisitByOffTime(VOffTime);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "ok";
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub HH:mm:ss
		try {
			if (VInTime != null && !VInTime.equals("")) {
				viewByInTime();
			} else
				viewAllVVisit();
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "ok";
	}

	/**
	 * @return the respondentId
	 */
	public String getRespondentId() {
		return respondentId;
	}

	/**
	 * @return the visitorId
	 */
	public String getVisitorId() {
		return visitorId;
	}

	/**
	 * @return the visitorInfoList
	 */
	public List<VVisitInfoPData> getVisitorInfoList() {
		return visitorInfoList;
	}

	/**
	 * @return the visitorList
	 */
	public List<VisitorTable> getVisitorList() {
		return visitorList;
	}

	/**
	 * @return the visitorManageSerI
	 */
	public VisitorManageSerI getVisitorManageSerI() {
		return visitorManageSerI;
	}

	/**
	 * @return the vOffPicture
	 */
	public String getVOffPicture() {
		return VOffPicture;
	}

	/**
	 * @param respondentId
	 *            the respondentId to set
	 */
	public void setRespondentId(String respondentId) {
		this.respondentId = respondentId;
	}

	/**
	 * @param visitorId
	 *            the visitorId to set
	 */
	public void setVisitorId(String visitorId) {
		this.visitorId = visitorId;
	}

	/**
	 * @param visitorInfoList
	 *            the visitorInfoList to set
	 */
	public void setVisitorInfoList(List<VVisitInfoPData> visitorInfoList) {
		this.visitorInfoList = visitorInfoList;
	}

	/**
	 * @param visitorList
	 *            the visitorList to set
	 */
	public void setVisitorList(List<VisitorTable> visitorList) {
		this.visitorList = visitorList;
	}

	/**
	 * @param visitorManageSerI
	 *            the visitorManageSerI to set
	 */
	public void setVisitorManageSerI(VisitorManageSerI visitorManageSerI) {
		this.visitorManageSerI = visitorManageSerI;
	}

	/**
	 * @param vOffPicture
	 *            the vOffPicture to set
	 */
	public void setVOffPicture(String vOffPicture) {
		VOffPicture = vOffPicture;
	}

	/**
	 * @return the vInTime
	 */
	public Timestamp getVInTime() {
		return VInTime;
	}

	/**
	 * @param vInTime
	 *            the vInTime to set
	 */
	public void setVInTime(Timestamp vInTime) {
		VInTime = vInTime;
	}

	/**
	 * @return the vOffTime
	 */
	public Timestamp getVOffTime() {
		return VOffTime;
	}

	/**
	 * @param vOffTime
	 *            the vOffTime to set
	 */
	public void setVOffTime(Timestamp vOffTime) {
		VOffTime = vOffTime;
	}

}
